package com.ls.lsojcodesandbox;

import com.ls.lsojcodesandbox.model.JudgeInfo;
import com.ls.lsojcodesandbox.model.entity.QuestionSubmit;
import com.ls.lsojcodesandbox.strategy.DefaultJudgeStrategy;
import com.ls.lsojcodesandbox.strategy.JavaLanguageJudgestrategy;
import com.ls.lsojcodesandbox.strategy.JudgeContext;
import com.ls.lsojcodesandbox.strategy.JudgeStrategy;
import org.springframework.stereotype.Service;

/**
 * @Classname JudgeManager
 * @Description 简化判题调用
 * @Date 2025/8/29 20:40
 * @Created by 李胜
 */
@Service
public class JudgeManager {

    public JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit;
        questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        if ("java".equals(language)) {
            judgeStrategy = new JavaLanguageJudgestrategy();
        } else if("cpp".equals(language)) {
            //调用C++的代码沙箱
        } else if("Python3".equals(language)){
            //调用Python3的代码沙箱
        } else {

        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
